// 导入组件
import Vue from "vue";
import Router from "vue-router";
// 登录
const login = () => import("@/views/login");
// 首页
const index = () => import("@/views/index");
// 主页
const Homepage = () => import("@/views/home/dashboard");

/**
 * 公共组件
 */
// 文件管理
const FileManage = () => import("@/views/baseCenter/fileManage");
// 环境变量
const CommonParam = () => import("@/views/baseCenter/commonParam");
/**
 * 环境中心
 */
// 环境管理
const EnvManage = () => import("@/views/envCenter/envManage");

const Functions = () => import("@/views/functions/functions")
/**
 * 用例中心
 */
// 接口管理
const InterfaceManage = () => import("@/views/caseCenter/interfaceManage");
// 接口编辑
const InterfaceEdit = () => import("@/views/caseCenter/interfaceEdit");
//元素管理
// const ElementManage= () => import('@/views/caseCenter/elementManage');
// 用例管理
const CaseManage = () => import("@/views/caseCenter/caseManage");
// API用例
const ApiCaseEdit = () => import("@/views/caseCenter/apiCaseEdit");
/**
 * 计划管理
 */
// 测试集合
const TestCollection = () => import("@/views/planCenter/testCollection");
// 测试集合编辑
const CollectionEdit = () => import("@/views/planCenter/collectionEdit");
// 测试计划
const TestPlan = () => import("@/views/planCenter/testPlan");
// 测试计划编辑
const PlanEdit = () => import("@/views/planCenter/planEdit");
/**
 * 测试追踪
 */
// 测试报告
const TestReport = () => import("@/views/report/testReport");
// 引擎管理
const ReportDetail = () => import("@/views/report/reportDetail");
/**
 * 配置中心
 */
// 系统配置
const SystemSetting = () => import("@/views/setting/systemSetting");
// 个人信息
const UserSetting = () => import("@/views/setting/userSetting");
/**
 * 系统管理
 */
// 项目管理
const projectManage = () => import("@/views/system/project");
// 角色管理
const RoleManage = () => import("@/views/system/role");
// 用户管理
const userManage = () => import("@/views/system/user");
//jmeter管理
const jmeter = () => import("@/views/system/jmeter");

// 启用路由
Vue.use(Router);

// 导出路由
export default new Router({
  routes: [
    {
      path: "/",
      name: "",
      component: login,
      hidden: true,
      meta: {
        requireAuth: false,
      },
    },
    {
      path: "/login",
      name: "登录",
      component: login,
      hidden: true,
      meta: {
        requireAuth: false,
      },
    },
    {
      path: "/index",
      name: "首页",
      component: index,
      children: [
        {
          path: "/home/dashboard",
          name: "主页",
          component: Homepage,
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/common/fileManage",
          name: "文件管理",
          component: FileManage,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/common/commonParam",
          name: "环境变量",
          component: CommonParam,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/envCenter/envManage",
          name: "环境管理",
          component: EnvManage,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/common/funs",
          name: "函数列表",
          component: Functions,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/interfaceManage",
          name: "接口管理",
          component: InterfaceManage,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/interfaceManage/add",
          name: "接口新增",
          component: InterfaceEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/interfaceManage/edit/:apiId",
          name: "接口编辑",
          component: InterfaceEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/caseManage",
          name: "最小用例单元",
          component: CaseManage,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/caseManage/apiCase/:type/:caseId",
          name: "API用例编辑",
          component: ApiCaseEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/caseManage/apiCase/:type",
          name: "API用例新增",
          component: ApiCaseEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/caseCenter/caseManage/apiCase/:type/:caseId",
          name: "API用例复用",
          component: ApiCaseEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/planManage/testCollection",
          name: "测试集合",
          component: TestCollection,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/planManage/testCollection/add",
          name: "测试集合新增",
          component: CollectionEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/planManage/testCollection/edit/:collectionId",
          name: "测试集合编辑",
          component: CollectionEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/planManage/testPlan",
          name: "测试计划",
          component: TestPlan,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/planManage/testPlan/add",
          name: "测试计划新增",
          component: PlanEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/planManage/testPlan/edit/:planId",
          name: "测试计划编辑",
          component: PlanEdit,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/report/testReport",
          name: "测试报告",
          component: TestReport,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/report/testReport/detail/:reportId",
          name: "报告详情",
          component: ReportDetail,
          meta: {
            requirePerm: "NORMAL_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/setting/systemSetting",
          name: "系统配置",
          component: SystemSetting,
          meta: {
            requirePerm: "SETTING_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/setting/userSetting",
          name: "用户信息",
          component: UserSetting,
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/systemManage/project",
          name: "项目管理",
          component: projectManage,
          meta: {
            requirePerm: "PROJECT_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/systemManage/role",
          name: "角色管理",
          component: RoleManage,
          meta: {
            requirePerm: "ROLE_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/systemManage/user",
          name: "用户管理",
          component: userManage,
          meta: {
            requirePerm: "USER_MENU",
            requireAuth: true,
          },
        },
        {
          path: "/systemManage/jmeter",
          name: "JMETER管理",
          component: jmeter,
          meta: {
            requirePerm: "JMETER_MENU",
            requireAuth: false,
          },
        },
      ],
    },
  ],
});
